<template>
	<view class="container">
		<u-sticky offset-top="10">
			<view class="search">
				<u-search placeholder="请输入员工昵称" :showAction="false" :borderColor="'#eeeeee'" :bgColor="'#ffffff'"
					v-model="keyword" @change="queryempleey"></u-search>
			</view>
		</u-sticky>

		<u-modal :show="showmodal"  :cancel="cancelmodal" :content='content'></u-modal>


		<u-empty v-if="empty==true"   mode="car" icon="http://cdn.uviewui.com/uview/empty/car.png">
		</u-empty>


		<view class="Box" v-if="type=='all'">
			<view class="list" v-for="item in list" :key="item.id">
				<view class="left">
					<u-checkbox-group v-model="checkboxValue1" placement="column" @change="checkboxChange">
						<u-checkbox :customStyle="{ marginBottom: '8px' }" v-for="(item, index) in item.emplist_text"
							:key="index" :label="item.name" :name="item.name">
						</u-checkbox>
					</u-checkbox-group>
				</view>
				<view class="center">
					<view class="image">
						<u-image :src="item.avatar_text" :shape="'circle'" :width="55" :height="55"
							:lazy-load="true"></u-image>

					</view>
				</view>
				<view class="right">
					<span>{{ item.nickname }}</span>
					<span class="store">{{ item.store_text }}</span>
				</view>

			</view>




		</view>
		<view class="Box" v-if="type=='find'">
			<view class="list" :key="item.id">
				<view class="left">
					<u-checkbox-group v-model="checkboxValue1" placement="column" @change="checkboxChange">
						<u-checkbox :customStyle="{ marginBottom: '8px' }" v-for="(item, index) in list.emplist_text"
							:key="index" :label="item.name" :name="item.name">
						</u-checkbox>
					</u-checkbox-group>
				</view>
				<view class="center">
					<view class="image">
						<u-image :src="list.avatar_text" :shape="'circle'" :width="55" :height="55"
							:lazy-load="true"></u-image>

					</view>
				</view>
				<view class="right">
					<span>{{ list.nickname }}</span>
					<span class="store">{{ list.store_text }}</span>
				</view>

			</view>




		</view>

		<view class="btn">

			<u-button :customStyle="{ width: '130px', height: '35px' }" type="primary" @click="surebtn" text="确定"></u-button>
			<view class="text">
				<span>已选择:</span>
				<span class="nickname">{{ empid }}</span>
			</view>
		</view>








		<!-- 消息提醒 -->
		<u-toast ref="notice"></u-toast>


	</view>
</template>

<script>
export default {
	onLoad() {
		this.auth = this.$u.auth.check()
		this.queryemplist()
	},
	created() {

		this.timer = setInterval(() => {

			let a = this.$u.count.check()

		}, 5000);

	},
	beforeDestroy() {
		clearInterval(this.timer)
	},
	data() {
		return {
			checkboxValue1: [],
			keyword: "",
			// 基本案列数据
			emplist_text: [{
				name: '2',
				disabled: false,

			},
			],
			showmodal:false,
			content:"你未选中筛选的员工",
			empty:false,
			type:"",
			empid: "",
			auth: {},
			show: false,
			keyword: '',
			list: [],
			list:[]

		}
	},
	methods: {

		async queryempleey(e) {
			this.keyword=e

			let result = await this.$u.api.admin.queryempleey({ adminid: this.auth.id,keyword:this.keyword})
			if (result.code) {
				if(result.data.empty == true)
				{

					this.empty = true
				}else
				{
					this.type = ""
					this.type = result.data.type

					this.list = result.data.list
				}
			}
		},

		 surebtn(e)
		{
			console.log(this.empid)
			// if(this.empid == "")
			// {
			// 	this.showmodal = true

			// }

			uni.setStorageSync("empid",this.empid)


			uni.reLaunch({
				url:"/pages/index/index",

			})
		
		},
		cancelmodal()
		{
			this.showmodal = false
		},

		checkboxChange(e) {
			this.empid = e[0]
		},
		async queryemplist() {
			let data = {
				adminid: this.auth.id,
				stoid: this.auth.stoid,
			}

			let result = await this.$u.api.admin.selectempleey(data)
			if (result.code) {
				if(result.data.list.length>0)
				{
					this.type = result.data.type
					this.list = result.data.list
				}else
				{
					this.empty = true
				}
			}

		}
	}
}
</script>

<style lang="scss">
.container {
	height: 1500rpx;
	width: 100%;
	margin: 0 30rpx;
	position: relative;
}

.search {
	margin-top: 25px;
	width: 88%;

}

.text {
	width: 300px;
	padding-left: 200px;

	.nickname {
		color: rgb(0, 102, 255)
	}
}

.list {
	width: 100%;
	height: 85px;
	border-bottom: 1px solid #eeeeee;
	display: flex;
	align-items: center;

}

.center {
	margin-left: 15px;
}

.right {
	margin-left: 15px;
}

.u-checkbox-group--column.data-v-3d1b15f2 {
	margin-top: 10px;
}

.store {
	margin: 0px 15px;
}


.Box {
	height: 600px;
	width: 100%;
	overflow: auto;
}

.u-button--plain.u-button--primary.data-v-3bf2dba7 {
	margin-left: 20px;
}

.btn {
	width: 86%;
	display: flex;
	justify-content: space-around;
	align-items: center;


}
</style>